<template>
  <page-header-wrapper :title="false">
    <a-card :body-style="{ padding: '24px 32px' }" :bordered="false">
      <a-form @submit="handleSubmit" :form="form">
        <a-form-item
          label="经销商"
          :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
          :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
        >
          <a-select v-decorator="['supplyId']" placeholder="请选择经销商">
            <a-select-option :value="i.id" v-for="i in supplyoption" :key="i.id">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item :wrapperCol="{ span: 24 }" style="text-align: center">
          <a-button htmlType="submit" type="primary" icon="check">下一步</a-button>
          <!-- <a-button style="margin-left: 8px">{{ $t('form.basic-form.form.save') }}</a-button> -->
        </a-form-item>
      </a-form>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { getSuppliesListUsingPOST } from '@/api/api/jingxiaoshangyunyingshangguanli.ts'
export default {
  name: 'BackDetails',
  data() {
    return {
      form: this.$form.createForm(this),
      optionParam: {
        pageNo: 1,
        pageSize: 999,
        queryCondition: '',
        status: 1,
      },
      supplyoption: [],
    }
  },
  mounted() {
    this.getSupOption()
  },
  methods: {
    getSupOption() {
      getSuppliesListUsingPOST({ ...this.optionParam, typesList: '2,3' })
        .then((res) => {
          this.supplyoption = res.data.list
        })
        .catch((error) => {
          this.$message.error(((error.response || {}).data || {}).msg || '请求出现错误')
        })
    },
    // handler
    handleSubmit(e) {
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          if(!values.supplyId){
              this.$message.warn('请选择经销商')
            }else{
              this.$router.push({ path: `/wholesale/backShopList/${this.$route.params?.id}`, query: { ...values } })
            }
        }
      })
    },
  },
}
</script>
